import { axiosInstance } from "..";
import { encrypt } from "@/utils/secretKey";

function Login(username: string, password: string) {
  password = encrypt(password);
  return new Promise((resolve, reject) => {
    axiosInstance()
      .post("/material/author/login", { username, password })
      .then(
        (res: any) => {
          resolve(res);
        },
        (error: any) => {
          reject(error);
        }
      );
  });
}

function MuteLogin(username: string, password: string) {
  password = encrypt(password);
  return new Promise((resolve, reject) => {
    axiosInstance()
      .post("/material/author/mutelogin", { username, password })
      .then(
        (res: any) => {
          resolve(res);
        },
        (err: any) => {
          reject(err);
        }
      );
  });
}

export { Login, MuteLogin };
